package com.example.nep.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.nep.model.GridMember;
import com.example.nep.dao.GridMemberMapper;
import com.example.nep.service.IGridMemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author han
 * @since 2024-04-11
 */
@Service
public class GridMemberServiceImpl extends ServiceImpl<GridMemberMapper, GridMember> implements IGridMemberService {

    @Override
    public GridMember login(String gmCode, String password) {
        LambdaQueryWrapper<GridMember> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(GridMember::getGmCode,gmCode)
                .eq(GridMember::getPassword,password);
        return getOne(wrapper);
    }

    @Override
    public List<GridMember> gmAll(Integer cityId, Integer provinceId) {
        LambdaQueryWrapper<GridMember> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(GridMember::getProvinceId,provinceId)
                .eq(GridMember::getCityId,cityId)
                .eq(GridMember::getState,0);
        return list(wrapper);
    }
}
